import cameraService from '@/services/camera.service'
//摄像头模块
const camera = {
    namespaced : true,
    state : {
        cameraList : [],
        rtcServers: []
    },
    mutations: {
        set_cameras: (state , payload) => {
            state.cameraList = payload
        },
        set_rtcservers: (state , payload) => {
            state.rtcServers = payload
        }
    },
    actions: {
        loadCameras: async ({ commit }, payload) => {
            cameraService.queryCameraList(payload).then((result)=>{
                if(result && result.code ===200 ){
                    console.log(result)
                    commit("set_cameras", result.data);
                }
            })
        },
        initCameras: async ({ commit }, rtcServers) => {
            if(rtcServers){
                commit("set_rtcservers",rtcServers)
            }
        }
    },
    getters: {
        cameraList : state => state.cameraList ? state.cameraList : [],
        rtcServers : state => state.rtcServers ? state.rtcServers : []
    }

}
export default camera